package com.dev.base.ability;


import com.dev.base.able.BaseModel;
import com.dev.base.able.IModelLisenner;
import com.dev.base.bean.BaseBean;
import com.dev.base.expand.mvvm.BaseViewModel;
import ohos.aafwk.ability.Lifecycle;
import ohos.aafwk.content.Intent;
import ohos.app.Context;

public class MainViewModel extends BaseViewModel implements IModelLisenner {
    private MainModel mainModel;

    public MainViewModel(Context mContext) {
        super(mContext);
        mainModel=new MainModel();
        mainModel.init();
        mainModel.setiModelLisenner(this);
        setiModelLisenner(this);

    }

    @Override
    protected BaseModel getViewModel() {
        return mainModel;
    }

    public void login(){
        showProgressDialog();
        mainModel.login();
    }
    @Override
    public void onHosComplete(int flag) {
    }

    @Override
    public void onHosNext(BaseBean bean) {
        dismiss();
        getiBaseViewModel().getData(bean);
    }

    @Override
    public void onHosError(int flag, Throwable e) {
    }
    @Override
    public void onStateChanged(Lifecycle.Event event, Intent intent) {
             if(Lifecycle.Event.ON_START == event){

             }else if(Lifecycle.Event.ON_ACTIVE == event){

             }else if(Lifecycle.Event.ON_BACKGROUND == event){

             }else if(Lifecycle.Event.ON_FOREGROUND == event){

             }else if(Lifecycle.Event.ON_INACTIVE == event){

             }else if(Lifecycle.Event.ON_STOP == event){

             }else if(Lifecycle.Event.UNDEFINED == event){

             }

    }
}
